﻿<?php echo validation_errors(); ?>

<?php echo form_open('home/') ?>
Розміри
<div id="size_block">

<?php
$cnt = $i = 0;

foreach ($filters as $filters_item):

	$i++;
?>
	<div <?= empty($filter_size[$i]) ? ' class="adjust" ' : ' class="in_use adjust" ' ?>>
<?php
	$val = $filters_item['value'] . (empty($filters_item['value_to']) ? '' : '-' . $filters_item['value_to']);
?>
		
		<input type="checkbox" name="filter_size[<?= $i ?>]" id="s_<?= $i ?>" value="<?= $val ?>" <?= empty($filter_size[$i]) ? ' class="s_chck"' : ' checked="checked" class="in_use s_chck"' ?> /><label for="s_<?= $i ?>"><?= $val; ?></label>
	</div>
<?php
	if( $cnt++ >= 14) {
		$cnt = 0;
?>
	<div style="clear:both"></div>
<?php
	}
endforeach
?>
	<div style="clear:both">
		<input type="button" id="cancel_size" value="Відключити розміри" />
	</div>
</div>
<div id="season_block"> 
	<div <?= empty($filter_season[0]) ? ' class="adjust"' : ' class="adjust ss_in_use"' ?>>
		<input type="checkbox" name="filter_season[0]" id="ss_0" value="1" <?= empty($filter_season[0]) ? '' : ' checked="checked"' ?> /><label for="ss_0">Всі</label>
	</div>
<?php
$cnt = $i = 0;

foreach ($seasons as $seasons_item):

	$i++;
?>
	<div <?= empty($filter_season[$i]) ? ' class="adjust_season" ' : ' class="ss_in_use adjust_season" ' ?>>
<?php
	$val = $seasons_item['name'] . ( $seasons_item['year_start'] > 0 ? ' ' . $seasons_item['year_start'] . '-' . $seasons_item['year_end'] : '');
?>
		
		<input class="ss_chck" type="checkbox" name="filter_season[<?= $i ?>]" id="ss_<?= $i ?>" value="<?= $seasons_item['id'] ?>" <?= empty($filter_season[$i]) ? '' : ' checked="checked"' ?> /><label for="ss_<?= $i ?>"><?= $val; ?></label>
	</div>
<?php
	if( $cnt++ >= 8) {
		$cnt = 0;
?>
	<div style="clear:both"></div>
<?php
	}
endforeach
?>
</div><div style="clear:both"></div><br />
</div>
<div>
	Ціна від <input type="text" name="price_from" value="<?= $price_from ?>" size="4" <?= empty($price_from) ? '' : ' class="in_use" ' ?> /> до <input type="text" name="price_to" value="<?= $price_to ?>" size="4" <?= empty($price_to) ? '' : ' class="in_use" ' ?> />
</div><br />
<div>
	Назва <input type="text" name="item_name" value="<?= $item_name ?>" <?= empty($item_name) ? '' : ' class="in_use" ' ?> />
</div><br />
<div>
	Код <input type="text" name="item_code" value="<?= $item_code ?>" <?= empty($item_code) ? '' : ' class="in_use" ' ?> />
</div><br />

<input type="submit" value="Шукати" />
<br />
<br />
<?php
$_seasons = $filter_season;
unset( $_seasons[0] );
$_seasons = empty( $_seasons ) ? 0 : implode( '.', $_seasons )
?>
Поділитись: <?= base_url();?>home/index/<?= empty( $filter_size ) ? 0 : implode( '.', $filter_size ) ?>/<?= empty($price_from) ? 0 : $price_from ?>/<?= empty($price_to) ? 0 : $price_to ?>/<?= empty($item_name) ? -1 : rawurlencode( $item_name ) ?>/<?= empty($item_code) ? -1 : rawurlencode( $item_code ) ?>/<?= $_seasons ?>

<br />
</form>
<br />
<?php
if( !empty($items) )
{
?>
	<table cellpadding="5" border="1">
		<tr>
			<th>Назва</th>
			<th>Код</th>
			<th>Розмір</th>
			<th>Ціна</th>
			<th>К-ть</th>
			<th>Зображення</th>
			<th>Опис</th>
		</tr>
<?php
	foreach ($items as $an_item) {
?>
		<tr id="item[<?= $an_item['item_id']?>]">
			<td><?= $an_item['name'] ?></td>
			<td><?= $an_item['file_name'] ?></td>
			<td><?= $an_item['size'] ?><?= empty($an_item['size_to']) ? '' : '-'.$an_item['size_to'] ?></td>
			<td><?= $an_item['price'] ?></td>
			<td><?= $an_item['amount'] ?></td>
			<td>
				<a href="<?= base_url().IMAGE_DIR.$an_item['file_name'] ?>.jpg" class="preview" target="_blank" title="<?= $an_item['name'] ?>"><img class="img_thumb" src="<?= base_url().IMAGE_DIR.$an_item['file_name'] ?>.jpg" alt="<?= $an_item['name'] ?>" /></a>
			</td>
			<td class="descript"><?= $an_item['description'] ?></td>
		</tr>
<?php
	}
?>
	</table>
<?php
}
?>